import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dell
 * Date: 2023-11-28
 * Time: 17:38
 */

class Student implements Comparable<Student>{
    String name;
    int age;

    double soure;

    public Student(String name, int age, double soure) {
        this.name = name;
        this.age = age;
        this.soure = soure;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", soure=" + soure +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.age-o.age;
    }
}
public class test2 {
    public static void main2(String[] args) {
        Student student1=new Student("add",11,88.8);
        Student student2=new Student("cdd",12,78.8);
        int ret= student1.compareTo(student2);
        System.out.println(ret);
    }
    public static void main(String[] args) {
        Student[] students=new Student[7];
        students[0]=new Student("jzj",12,72.1);
        students[1]=new Student("zkp",15,92.1);
        students[2]=new Student("mzh",14,82.1);
        students[3]=new Student("ljc",22,84.1);
        students[4]=new Student("add",18,66.1);
        students[5]=new Student("cbb",74,56.1);
        students[6]=new Student("hjh",54,99.1);
        System.out.println(Arrays.toString(students));
        //  Arrays.sort(students);
        // System.out.println(Arrays.toString(students));
        bubblesort(students);
        System.out.println(Arrays.toString(students));

//        System.out.println(students[0]);
//        System.out.println(students[1]);
//        System.out.println(students[2]);
    }
    public static void bubblesort(Comparable[] comparables){
        for (int i=0;i<comparables.length-1;i++){
            for (int j=0;j<comparables.length-i-1;j++){
                if(comparables[j].compareTo(comparables[j+1])>0){
                    Comparable tmp=comparables[j];
                    comparables[j]=comparables[j+1];
                    comparables[j+1]=tmp;
                }
            }
        }
    }
}